-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tweaks to the NFT agents #614
Conversation
Caution Review failedThe pull request is closed. WalkthroughThis pull request introduces modifications across several files in the Changes
Suggested reviewers
Possibly related PRs
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
prediction_market_agent/agents/microchain_agent/nft_treasury_game/app_nft_treasury_game.py (1)
199-203
: Consider caching the NFT balance queryThe NFT balance query is made every time the component refreshes (every 5 seconds). Consider caching this value or reducing the refresh frequency to minimize blockchain calls.
- n_nft = BalanceOfNFT()(NFT_TOKEN_FACTORY, nft_agent.wallet_address) + @st.cache_data(ttl=60) # Cache for 60 seconds + def get_nft_balance(address: str) -> int: + return BalanceOfNFT()(NFT_TOKEN_FACTORY, address) + + n_nft = get_nft_balance(nft_agent.wallet_address)prediction_market_agent/agents/microchain_agent/nft_treasury_game/deploy_nft_treasury_game.py (2)
204-205
: Clarify message fee structureThe prompt should be more explicit about the fee split between recipient and treasury to avoid confusion.
-Receiving messages will pay you a fee, but part of that fee goes to the treasury, which is good for you. +Receiving messages will pay you a fee (X% of the message cost), with the remaining Y% going to the treasury, benefiting both parties.
Line range hint
186-207
: Improve prompt structure and readabilityThe base prompt could be better organized by grouping related information.
Consider restructuring the prompt into clear sections:
- Game Overview
- NFT Contract Details
- Communication Rules & Fees
- Treasury Mechanics
- Important Limitations
def nft_treasury_game_base_prompt(wallet_address: ChecksumAddress) -> str: keys = MicrochainAgentKeys() other_agents_keys_formatted = ", ".join( x.wallet_address for x in DEPLOYED_NFT_AGENTS if x.wallet_address != wallet_address ) - return f"""NFT Treasury game description: + return f"""# NFT Treasury Game Description + +## Game Overview +- You participate in the securing of the NFT key to a treasury. +- The agent or person who gets enough of keys, can transfer the resources from the treasury. + +## Participant Information +- Your wallet address is {wallet_address} +- Other agents participating and maybe still holding keys are {other_agents_keys_formatted} +- Address of the treasury, wallet holding the treasury's Xdai, is {TREASURY_SAFE_ADDRESS} + +## NFT Contract Details +- Address of the NFT contract is {NFT_TOKEN_FACTORY} +- There are 5 keys, with token_id 0, 1, 2, 3, 4 +- You can own multiple NFT keys +- You can use the NFT functions to interact with the NFT keys + +## Communication Rules & Fees +- Agents can communicate using messages sent to wallet addresses +- Sending a message incurs a fee +- Receiving messages pays you a fee, with a portion going to the treasury +- Process unseen incoming messages first (unless already processing a message) + +## Important Limitations +- Maximum sending limit: {keys.SENDING_XDAI_CAP} xDai per transaction +- Regularly check balances of your wallet and the treasury """
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
prediction_market_agent/agents/microchain_agent/microchain_agent.py
(1 hunks)prediction_market_agent/agents/microchain_agent/microchain_agent_keys.py
(2 hunks)prediction_market_agent/agents/microchain_agent/nft_treasury_game/app_nft_treasury_game.py
(3 hunks)prediction_market_agent/agents/microchain_agent/nft_treasury_game/deploy_nft_treasury_game.py
(3 hunks)prediction_market_agent/agents/microchain_agent/nft_treasury_game/messages_functions.py
(3 hunks)tests/agents/microchain/test_messages_functions.py
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- tests/agents/microchain/test_messages_functions.py
🔇 Additional comments (9)
prediction_market_agent/agents/microchain_agent/microchain_agent_keys.py (2)
1-1
: LGTM! Import statement updated for type safety
The addition of xdai_type
import aligns with the type safety improvements in the codebase.
12-12
: Verify the impact of changing SENDING_XDAI_CAP initialization value
The initialization value has been changed from OMEN_TINY_BET_AMOUNT
to xdai_type(0.1)
. While this improves type safety, we should verify this doesn't impact existing functionality.
✅ Verification successful
Change to SENDING_XDAI_CAP is safe and improves type safety
The change from OMEN_TINY_BET_AMOUNT
to xdai_type(0.1)
for SENDING_XDAI_CAP
is safe because:
SENDING_XDAI_CAP
is only used as an upper limit for transaction amounts in themicrochain_agent_keys.py
- The value is only referenced in documentation string in
deploy_nft_treasury_game.py
- The change to use
xdai_type(0.1)
directly improves type safety while maintaining similar functionality OMEN_TINY_BET_AMOUNT
is still used separately forRECEIVER_MINIMUM_AMOUNT
where it's more contextually appropriate
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for usages of SENDING_XDAI_CAP to understand impact
rg -l "SENDING_XDAI_CAP"
# Search for OMEN_TINY_BET_AMOUNT to understand its usage
rg "OMEN_TINY_BET_AMOUNT"
Length of output: 503
Script:
#!/bin/bash
# Let's check how SENDING_XDAI_CAP is used in the deploy_nft_treasury_game.py
rg "SENDING_XDAI_CAP" prediction_market_agent/agents/microchain_agent/nft_treasury_game/deploy_nft_treasury_game.py -A 2
# Let's also check the actual value of OMEN_TINY_BET_AMOUNT
rg "OMEN_TINY_BET_AMOUNT\s*=\s*" -A 1 prediction_market_agent/agents/microchain_agent/tooling/markets/omen/omen.py
Length of output: 473
Script:
#!/bin/bash
# Let's try to find the correct path for omen.py file
fd omen.py
# Let's also check the actual implementation to see how SENDING_XDAI_CAP is used in the code
ast-grep --pattern 'SENDING_XDAI_CAP'
Length of output: 679
prediction_market_agent/agents/microchain_agent/nft_treasury_game/messages_functions.py (3)
42-46
: LGTM! Improved clarity in SendPaidMessageToAnotherAgent description
The description now clearly indicates the minimum fee requirement for message sending.
73-73
: LGTM! Enhanced message count visibility
The description now includes the count of unseen messages, improving user awareness.
48-56
: Verify the fee parameter type conversion
The new fee parameter is properly handled with type conversion, but we should ensure all callers are updated to provide the fee parameter.
prediction_market_agent/agents/microchain_agent/nft_treasury_game/app_nft_treasury_game.py (1)
72-75
: LGTM! Well-constrained value input
The value input is properly constrained with minimum and maximum values, using the system's minimum amount as default.
prediction_market_agent/agents/microchain_agent/microchain_agent.py (1)
47-48
: LGTM! Verify import references.
The reorganization of imports looks good, moving MESSAGES_FUNCTIONS under nft_treasury_game makes logical sense for better code organization. However, let's verify there are no broken references due to this change.
✅ Verification successful
Import changes are properly reflected across the codebase
The verification shows that all references to the messages_functions module have been properly updated to use the new location under nft_treasury_game. The test file and app_nft_treasury_game.py are correctly importing from the new path prediction_market_agent.agents.microchain_agent.nft_treasury_game.messages_functions
. No references to the old import path remain in active use.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify that the moved MESSAGES_FUNCTIONS import doesn't break any existing references
# Check for any direct imports of messages_functions from old location
rg -l "from prediction_market_agent.agents.microchain_agent.messages_functions import"
# Check for any references to the old module path
rg -l "microchain_agent.messages_functions"
# Check if the new module is properly referenced elsewhere
rg -l "microchain_agent.nft_treasury_game.messages_functions"
Length of output: 455
Script:
#!/bin/bash
# Let's check the content of the test file to see if it needs updating
cat tests/agents/microchain/test_messages_functions.py
# Also check the content of app_nft_treasury_game.py to verify proper import usage
cat prediction_market_agent/agents/microchain_agent/nft_treasury_game/app_nft_treasury_game.py
Length of output: 15532
prediction_market_agent/agents/microchain_agent/nft_treasury_game/deploy_nft_treasury_game.py (2)
14-14
: LGTM: NFT contract information import added
The addition of NFT_TOKEN_FACTORY
import enhances the agent's knowledge about NFT contract interactions.
198-200
: Verify NFT token IDs existence
The prompt mentions specific token IDs (0-4) but there's no validation to ensure these IDs exist in the contract.
prediction_market_agent/agents/microchain_agent/nft_treasury_game/app_nft_treasury_game.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
prediction_market_agent/agents/microchain_agent/nft_treasury_game/app_nft_treasury_game.py
(3 hunks)tests/agents/microchain/test_messages_functions.py
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- tests/agents/microchain/test_messages_functions.py
🔇 Additional comments (3)
prediction_market_agent/agents/microchain_agent/nft_treasury_game/app_nft_treasury_game.py (3)
19-32
: LGTM! Import statements are well-organized.
The new imports are logically grouped and necessary for the added NFT functionality and message handling.
72-80
: LGTM! Well-implemented value input with proper constraints.
The implementation properly handles xDai value input with:
- Minimum value validation
- Maximum cap for safety
- Proper decimal formatting
- Configuration-driven defaults
204-209
: Consider improving NFT balance message clarity.
While the implementation is functionally correct, the message could be clearer:
Apply this diff to improve clarity:
- "and does not hold any NFT keys anymore"
- if n_nft == 0
- else f"and <span style='font-size: 1.1em;'><strong>{n_nft} NFT key{'s' if n_nft > 1 else ''}</strong></span>"
+ "and does not hold NFT keys"
+ if n_nft == 0
+ else f"and holds <span style='font-size: 1.1em;'><strong>{n_nft} NFT key{'s' if n_nft > 1 else ''}</strong></span>"
This change aligns with the previous review suggestion while maintaining the existing styling.
build please